<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function checkId(){
				if(Id1()){
					return true;
				}
				return false;
			}
			function Id1(){
				var s = document.forms[0].id.value;
				
				var reg = /^\d{17}[0-9xX]$/;
				
				var d = reg.test(s);
				
				if(d){
					console.log(d);
					return true;
				}else{
					alert("重新输入身份证号")
					return false;
				}
				return true;
				
				
				
				
				
				
			}
		</script>
	</head>
	<body>
		<form action="正则练习.html" onsubmit="return checkId()">
			身份证号:<input type="text" name="id" size="18">
			<input type="submit" value="验证"/>
		</form>
	</body>
</html>
